package org.wzl._360mallbackend.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wzl._360mallbackend.dao.UserDao;
import org.wzl._360mallbackend.entity.User;
import org.wzl._360mallbackend.utils.Response;

import java.util.Objects;


@RestController
@RequestMapping("/user")
public class UserController {
    
    @Autowired
    private UserDao userDao;

    @PostMapping("/checkUser")
    public Response postMethodName(@RequestBody User user) {
        User checkUser = userDao.checkUser(user.getUsername() , user.getPassword());
        if (Objects.isNull(checkUser)) {
            return Response.fail("用户验证失败");
        }
        return Response.ok().putData("user", checkUser);
    }

    @PostMapping("/insert")
    public Response insert(@RequestBody User user) {
        userDao.insert(user);
        return Response.ok();
    }



}
